package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.DestinationTheme;
import cn.wolfcode.luowowo.article.mapper.DestinationThemeMapper;
import cn.wolfcode.luowowo.article.mapper.DestinationThemeTagMapper;
import cn.wolfcode.luowowo.article.query.DestinationThemeQuery;
import cn.wolfcode.luowowo.article.service.IDestinationThemeService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class DestinationThemeServiceImpl implements IDestinationThemeService {
    @Autowired
    private DestinationThemeMapper destinationThemeMapper;
    @Autowired
    private DestinationThemeTagMapper destinationThemeTagMapper;

    @Override
    public PageInfo query(DestinationThemeQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        return new PageInfo(destinationThemeMapper.selectForList(qo));
    }

    @Override
    public void saveOrUpdate(DestinationTheme destinationTheme) {
        if(destinationTheme.getId() == null){
            destinationThemeMapper.insert(destinationTheme);
        }else{
            destinationThemeMapper.updateByPrimaryKey(destinationTheme);
        }
    }

    @Override
    public List<DestinationTheme> list() {
        return destinationThemeMapper.selectAll();
    }

   



}
